<?php
/**
* Template to show all classes & traits within a repo.
*
* Template to be used by PHP code, not to be included by a .src.md file.
* TODO: Support interfaces
*
* @param $args[0] array<string fully_qualified_classname, array $ast> ASTs for each class scanned within the repo.
* @param $args[1] array<string fully_qualified_traitname, array $ast> ASTs for each trait scanned within the repo.
*/
//print_r($args);
//exit;
$class_list = array_merge(
// array shift to reduce memory footprint, i guess.
array_shift($args),
array_shift($args)
);
$test_classes = [];
$src_classes = [];
$traits = [];
$count = count($class_list);
while ($class = array_pop($class_list)){
$file = str_replace('//','/',$class['file']);
$class_basename = $class['name'];
$class_docs = $file.'.md';
$description = $class['docblock']['description'] ?? 'No description...';
$description = str_replace("\n", "\n ", trim($description));
$class_markdown = "- [`$class_basename`]($class_docs): $description"." ";
if ($class['type'] == 'trait'){
//print_r($class);
//exit;
$traits[] = $class_markdown;
} else if (substr($file,0,5)=='test/'
||substr($file,0,6)=='tests/'){
$test_classes[] = $class_markdown;
} else {
$src_classes[] = $class_markdown;
}
}
?>
<!-- Project Classlist generated by ast/ApiReadme template. -->
<!-- To Disable: Set api.generate_readme = false in your config.json -->
# All Classes
Browse <?=$count?> classes & traits in this project. There are <?=count($src_classes)?> source classes, <?=count($test_classes)?> test classes, and <?=count($traits)?> traits.
*Note: As of Dec 23, 2023, only classes & traits are listed. interfaces & enums are not supported.*
## Source Classes (not tests)
<?php
echo implode("\n", $src_classes);
echo "\n\n";
?>
## Traits
<?php
echo implode("\n", $traits);
echo "\n\n";
?>
## Test Classes
<?php
echo implode("\n", $test_classes);
echo "\n\n";
?>